package com.interest.controller.builder;

import java.util.HashMap;
import java.util.Map;

/**
 * ErrorModelAndViewBuilder, build View with error message
 *
 * Created by yangfeng on 16-11-10.
 */
public class ErrorModelAndViewBuilder extends ModelAndViewBuilder {
    private static final String VIEW_NAME = "error";  // bind to error.jsp

    private final String message;
    public ErrorModelAndViewBuilder(String message) {
        this.message = message;
    }

    protected String getViewName() {
        return VIEW_NAME;
    }

    @Override
    protected Map<String, ?> getDataMap() {
        HashMap<String, Object> map = new HashMap<>();
        map.put(VIEW_NAME, message);
        return map;
    }
}